#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *int_array;
	int no_els,i,no_bytes,sum;
	sum=0;
	printf("Enter the number of elements: ");
	scanf("%d",&no_els);
	/*Calculate the number of bytes required by the array.*/
	no_bytes=no_els*sizeof(int);
	/*Allocate the memory for the array.*/
	int_array=(int*)malloc(no_bytes);
	if(int_array==NULL)
	{
		printf("Cannot allocate number\n");
		return EXIT_FAILURE;	
	}
	for(i=0;i<no_els;i++)
	{
		printf("Enter element %d:",i);
		scanf("%d",&int_array[i]);
		sum=sum+int_array[i];
	}
    printf("The sum is %d\n",sum);	
	for(i=0;i<no_els;i++)
	free(int_array);	/*Free the allocated memory.*/
	return 0;
}

